<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>账户预付款信息</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript">
    var allFundState = ${allFundState};
    var allFundPayType = ${allFundPayType};
    var formSetting = {
        title: "预付款记录",
        module: 'query',
        numCount: '2',
        columns: [{
            index: "BID",
            name: "bid",
            label: "预付款编号"
        }, {
            index: "STATUS",
            name: "state",
            type: "dropdown",
            data: allFundState,
            label: "预付款状态",
            op: "eq"
        }, {
            index: "REGDATE",
            name: "regDate",
            type: "date",
            label: "预付款时间起",
            op: "ge"
        }, {
            index: "REGDATE",
            name: "regDate",
            label: "预付款时间止",
            type: "date",
            op: "le"
        }],
        buttons: {
            custom: [{
                id: "fundFlowbtn",
                value: "查看资金流水",
                click: function () {
                    window.location.href = "flow-main";
                }
            }, {
                id: "addbtn",
                value: "线下预付款！",
                click: function () {
                    window.location.href = "ajustment-view";
                }
            }, {
                id: "addbtn",
                value: "在线预付款！！",
                click: function () {
                    window.location.href = "ajustment-onlinePay";
                }
            }, {
                id: "updateBtn",
                value: "查看修改",
                click: function () {
                    var id = $("#dataGrid").jqGrid(
                            "getGridParam", "selrow");
                    if (id) {
                        var ret = $("#dataGrid").jqGrid(
                                'getRowData', id);
                        var flag = "在线支付";
                        if(ret.fundPayType === flag){
                            location.href = "ajustment-onlinePay?id=" + ret.id;
                        }else{
                            window.location.href = "ajustment-view?id=" + ret.id;
                        }
                    } else {
                        jw.alert("请先点击选择需要查看修改的记录!");
                    }
                }
            }]
        },
        grid: {
            id: "dataGrid",
            title: "查询结果",
            url: "ajustment-findList",
            colModel: [{
                index: "id",
                name: "id",
                label: "id",
                hidden: true
            }, {
                index: "bid",
                name: "bid",
                label: "预付款编号"
            }, {
                index: "amount",
                name: "amount",
                label: "预付款金额"
            }, {
                index: "state",
                name: "state",
                label: "预付款状态"
            }, {
                index: "fundPayType",
                name: "fundPayType",
                label: "预付款方式"
            }, {
                index: "regDate",
                name: "regDate",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                },
                label: "录入时间"
            }, {
                index: "reviewDate",
                name: "reviewDate",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                },
                label: "到账时间"
            }, {
                index: "regUser",
                name: "registrant.account",
                label: "录入账号"
            }],
            sortname: "regDate",
            sortorder: "desc",
            loadComplete: function (data) {
                $("td[aria-describedby='dataGrid_state']").each(function () {
                    $(this).text($(this).text() == "INIT" ? "支付中" : stateUtil.get(allFundState,
                                                                                  $(this).text()));
                });
                $("td[aria-describedby='dataGrid_fundPayType']").each(function () {
                    $(this).text(stateUtil.get(allFundPayType, $(this).text()));
                });
            }
        }
    };
    $(document).ready(function () {
        $("#dataTable").mrdForm(formSetting);
    });
    var stateUtil = {
        get: function (arras, key) {
            for (var a in arras) {
                if (arras[a][1] == key) {
                    return arras[a][0];
                }
            }
        }
    }
</script>
<body>
<div id="dataTable"></div>
</body>
</html>
